import 'package:merchants/services/base-service.dart';

class JoinMerchantService extends BaseService {
  JoinMerchantService({required super.ref});

  Future<bool> joinMerchant({
    required String merchantId,
    required String name,
    required String unionid,
  }) async {
    try {
      await post<Map<String, dynamic>>(
        '/merchants/$merchantId/apply',
        body: {},
        parser: (json) => json, // 对于纯文本响应，BaseService 会包装为 {data: text}
        requireToken: false,
        additionalHeaders: {'x-unionid': unionid},
      );

      // 只要请求未抛异常即视为成功
      return true;
    } catch (e) {
      throw ApiException('申请加入商户失败: $e');
    }
  }
}
